package com.puzzlebazar.client.hashiwokakero;

import com.puzzlebazar.client.puzzle.model.Move;
import com.puzzlebazar.client.puzzle.model.MoveVisitor;
import com.puzzlebazar.client.puzzle.model.PuzzleModel;
import com.puzzlebazar.client.util.Vec2i;

public class MoveRemoveBridge extends MoveBridge {


	/**
	 * 
	 */
	private static final long serialVersionUID = 6066389480603902925L;

	/**
	 * Only for serialization
	 */
	protected MoveRemoveBridge() {
		super();
	}
	
	/**
	 * A move that contains all the information required to delete a bridge
	 * 
	 * @param connection1 The location of the first end of the bridge
	 * @param connection2 The location of the second end of the bridge
	 * @param value The value of the bridge
	 */
	public MoveRemoveBridge(Vec2i connection1, Vec2i connection2, int value) {
		super(connection1, connection2, value);
	}


	@Override
	public Move apply(PuzzleModel model) throws Exception {
		return deleteBridge(model);
	}

	@Override
	public Move unapply(PuzzleModel model) throws Exception {
		return createBridge(model);
	}

	@Override
	public void accept(MoveVisitor visitor) throws Exception {
		if( !(visitor instanceof HashiwokakeroMoveVisitor) ) 
			super.accept(visitor);
		else
			((HashiwokakeroMoveVisitor)visitor).visitRemoveBridgeMove(this);
	}	
	
}
